
!  --------------------------------------------------
!  Silverfrost FTN95 for Microsoft Visual Studio
!  Fixed Format FTN95 Source File
!  --------------------------------------------------

!program RegFalsi
!implicit none
!implicit none
!real*8 epsilon, answer, x1, x2
!integer*2 count
!parameter (epsilon = 1.E-5)
!parameter (x1=1.E-3)
!parameter (x2=999*1.E-3)
!call metoderegulafalsi (epsilon,x1,x2,answer,count)
!print*,answer
!print*,count
!pause
!end


subroutine metoderegulafalsi (eps,a,b,jawaban,iter)
implicit none
real*8 a,b,eps,jawaban,c,tempa,tempb,f
integer*2 iter
iter = 0
tempa = a
tempb = b
do while (abs (tempa-tempb) > eps)
c = tempb-((f(tempb)*(tempb-tempa))/(f(tempb)-f(tempa)))
if(abs(f(c)) < 1.E-6) then
    tempa=c
    tempb=c
    jawaban = c
    exit  
end if 
if ((f(tempa)*f(c)) < 0) then
        tempb=c
else
        tempa=c
    end if
iter = iter +1
end do
end

!real*8 function f(x)
!implicit none
!real*8 x
!f = ((x*((2.1-(0.5*x))**0.5)) / ((1-x)*((1.1-(0.5*x))**0.5))) - 3.69
!end